<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>演员资料列表</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/actor/list?cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/actor/list?cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 44,
            width: document.body.clientWidth - 1
        });
    });

    function getRowData(value, rec) {
        var id = rec.id;

    }

    function save() {
        document.forms[1].submit();
    }

    function check() {

    }

    function add() {
        var url = "${pageContext.request.contextPath }/actor/init";
        //var title="演员新增";
        //addTab1(title, url);
        window.location.href = url;

    }

    function del() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要删除的演员");
            return;
        }
        if (!confirm('删除确认')) {
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        var url = "${pageContext.request.contextPath }/actor/del?ids=" + arr;
        location.href = url;
    }

    function edit() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要修改的演员");
            return;
        }
        url = "${pageContext.request.contextPath }/actor/update?actorId=" + ids[0].value;
        location.href = url;

    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }
</script>

<form action="${pageContext.request.contextPath }/actor/list" method="post" onsubmit="check();">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" BACKGROUND="images/maintitle.jpg" class="tablelist2">
        <tr>
            <td align="left" class="tableselect2">
                <div class="tools">
                    <ul class="toolbar">
                        <li><a href="javascript:void(0);" onclick="add();"><span><img
                                src="${pageContext.request.contextPath }/images/add.png"></span>添加</a></li>
                        <li><a href="javascript:void(0);" onclick="edit();"><span><img
                                src="${pageContext.request.contextPath }/images/Mod.png"></span>修改</a></li>
                        <li><a href="javascript:void(0);" onclick="del();"><span><img
                                src="${pageContext.request.contextPath }/images/delete.png"></span>删除</a></li>
                    </ul>
                </div>
            </td>
            <td align="right" class="tableselect2">
                &nbsp;
            </td>
        </tr>
    </table>
</form>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px" singleSelect="false"
       data-options="onClickRow:getRowData">
    <thead>
    <tr>
        <th field="id" checkbox="true" width=50>选择</th>
        <th field="actorId" width=200 align="center">演员编号</th>
        <th field="actorName" width=200 align="center">演员名称</th>
        <th field="cimg" width=200 align="center">相片</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" var="v">
        <tr>
            <td>${v.actorId }</td>
            <td>${v.actorId}</td>
            <td>${v.actorName }</td>
            <td><img src="${pageContext.request.contextPath }/${v.cimg}" height="40"></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>